package com.coreJava.testio.socket;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;

/**
 * 作者: LCG
 * 日期: 2019/9/6 15:58
 * 描述:
 */
public class SocketServer {

    public static HashMap<String, String> socketMap = new HashMap<>();

    public static void main(String[] args) throws IOException, InterruptedException {

            ServerSocket serverSocket=new ServerSocket(10000);

            while(true){

                Socket accept = serverSocket.accept();

                InputStream inputStream = accept.getInputStream();

                InputStreamReader inputStreamReader=new InputStreamReader(inputStream);

                BufferedReader bufferedReader=new BufferedReader(inputStreamReader);

                String str=bufferedReader.readLine();

                System.out.println("接收信息=>"+str);

                //使用PrintWriter和BufferedReader进行读写数据
                PrintWriter pw = new PrintWriter(accept.getOutputStream());
                //发送数据
                pw.println("Server OK !--->"+socketMap.get("1"));

                pw.flush();

            }


    }

}
